﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for A2.xaml
    /// </summary>
    public partial class A2 : UserControl
    {
        public A2()
        {
            
        }
        static int a = 0;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftShift))
            {
                if (Switch.Template != this.FindResource("SwitchTemplate_2"))
                {
                    Switch.Template = this.FindResource("SwitchTemplate_2") as ControlTemplate;
                }
            }
            else
            {
                if (Switch.Template != this.FindResource("SwitchTemplate_1"))
                {
                    Switch.Template = this.FindResource("SwitchTemplate_1") as ControlTemplate;
                }
                VisualStateManager.GoToState(Switch, (++a % 2) != 0 ? "List" : "Tree", true);
            }

        }

        private void ItemsControl_KeyUp(object sender, KeyEventArgs e)
        {
            var i = sender as ItemsControl;
            i.Template = this.FindResource("SwitchTemplate_2") as ControlTemplate;
        }
    }
}
